package org.pada.client.dto;

/**
 * @author pengshen
 * @date 2023.12.29 18:00
 */
public class SingleResp<T> extends Resp {

    private T data;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static SingleResp buildSuccess() {
        SingleResp resp = new SingleResp();
        resp.setSuccess(true);
        return resp;
    }

    public static SingleResp buildFailure(String errCode, String errMessage) {
        SingleResp resp = new SingleResp();
        resp.setSuccess(false);
        resp.setErrCode(errCode);
        resp.setErrMessage(errMessage);
        return resp;
    }

    public static <T> SingleResp<T> of(T data) {
        SingleResp<T> resp = new SingleResp<>();
        resp.setSuccess(true);
        resp.setData(data);
        return resp;
    }
}
